<?php
defined('IN_TS') or die('Access Denied.');

$userid = aac('user')->isLogin();

$wishid	= intval($_POST['wishid']);
$content	= tsClean($_POST['content']);
$corp = trim($_POST['corp']);
$number = trim($_POST['number']);
$kuaidi = $corp.$number;

$text = strip_tags($_POST['content'],'<img>');
if($text==''){
	$content = $kuaidi;
	if($kuaidi&&($corp==''||($corp!='自送'&&$number==''))){
		tsNotice('快递单号不全');
	}
}

if($text == ''&& $kuaidi ==''){
	tsNotice('内容不能为空');
}


if($TS_USER['isadmin']==0){
	//过滤内容开始
	aac('system')->antiWord($content);
	//过滤内容结束
}

$commentid = $new['wish']->create('wish_comment',array(
	'wishid'			=> $wishid,
	'userid'			=> $userid,
	'content'	=> $content,
	'addtime'		=> time(),
));

if($kuaidi){
	$new['wish']->update('wish_users',array('wishid'=>$wishid,'userid'=>$TS_USER['userid']),array('status'=>1));
}

$strWish = $new['wish']->getWishByWishid($wishid);
if($strWish['userid'] != $TS_USER['userid']){
	$msg_userid = '0';
	$msg_touserid = $strWish['userid'];
	$msg_content = '你发布的心愿《'.$strWish['title'].'》新增一条评论，快去看看吧^_^ ';
	$msg_tourl = tsUrl('wish','show',array('id'=>$wishid));
	aac('message')->sendmsg($msg_userid,$msg_touserid,$msg_content,$msg_tourl);
}

header("Location: ".tsUrl('wish','show',array('id'=>$wishid)));